﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Pyramid.VsOnline.Core.Services;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Pyramid.VsOnline.Core.Model;
namespace Pyramid.VsOnline.Core.Services.Tests
{
    [TestClass()]
    public class TfsManagerTest
    {
        string loginParameters = "-login:chingangbam.irabanta@pyramidci.com,Pyramid!795004";
        [TestMethod()]
        public void GetWorkspacesTest()
        {
            var args=@"workspaces|-format:brief|-server:https://apg-alogent.visualstudio.com/DefaultCollection|" + loginParameters;
            var arguments = args.Split(new char[] { '|' });
            var parameterParser = new TfsParamParser();
            var tfsParameters = parameterParser.Parse(arguments);
            var tfsManager = new TfsManager();
            tfsManager.GetWorkspaces(tfsParameters);
        }

        [TestMethod()]
        public void CreateWorkspaceTest()
        {
            var args="workspace|-new|Hudson-Pyramid MVC5 Template-MASTER;chingangbam.irabanta@pyramidci.com|-noprompt|-server:https://irabanta.visualstudio.com/DefaultCollection|" + loginParameters;
            var arguments = args.Split(new char[] { '|' });
            var parameterParser = new TfsParamParser();
            var tfsParameters = parameterParser.Parse(arguments);
            var tfsManager = new TfsManager();
            tfsManager.CreateWorkspace(tfsParameters);
        }

        [TestMethod()]
        public void MapWorkspaceTest()
        {
            var args=@"workfold|-map|$/Pyramid Templates/OnionArch_MVC/Trunk|C:\Users\irabantac\.hudson\jobs\Pyramid MVC5 Template\workspace|-workspace:Hudson-Pyramid MVC5 Template-MASTER|-server:https://irabanta.visualstudio.com/DefaultCollection|" + loginParameters;
            var arguments = args.Split(new char[] { '|' });
            var parameterParser = new TfsParamParser();
            var tfsParameters = parameterParser.Parse(arguments);
            var tfsManager = new TfsManager();
            tfsManager.MapWorkspace(tfsParameters);
            tfsManager.DownloadLatestFiles(tfsParameters);
        }

        [TestMethod()]
        public void GetLatestVersionTest()
        {
            var args=@"get|C:\Users\irabantac\.hudson\jobs\Pyramid MVC5 Template\workspace|-recursive|-version:D2014-08-24T11:57:26Z|-noprompt|-server:https://irabanta.visualstudio.com/DefaultCollection|" + loginParameters;
            var arguments = args.Split(new char[] { '|' });
            var parameterParser = new TfsParamParser();
            var tfsParameters = parameterParser.Parse(arguments);
            var tfsManager = new TfsManager();
            tfsManager.GetLatestVersion(tfsParameters);
        }
    }
}
